package com.wanglibao.woodtrade.woodtrade.ui.fragment.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wanglibao.woodtrade.woodtrade.R;
import com.wanglibao.woodtrade.woodtrade.ui.fragment.adapter.model.NewDemand;


public class ItemLvFragmentHomeDeandAdapter extends BaseAdapter {


    NewDemand newDemand;
    private Context context;

    public ItemLvFragmentHomeDeandAdapter(Context context,NewDemand newDemand) {
        this.context = context;
        this.newDemand = newDemand;
    }

    @Override
    public int getCount() {
        return newDemand.getList().size();
    }

    @Override
    public NewDemand.ListBean getItem(int position) {
        return newDemand.getList().get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView textView = null;
        if (convertView == null) {
            convertView = View.inflate(context,R.layout.item_lv_fragment_home_deand, null);
            textView = (TextView) convertView.findViewById(R.id.tv_item_lv_fragment_home_deand_view);
            convertView.setTag(textView);
        }else{
            textView = (TextView) convertView.getTag();
        }
        textView.setText(newDemand.getList().get(position).getTitle());
        return convertView;
    }

}
